WatchView.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. 'use client';
  2. import { useState } from 'react';
  3. import { ChannelDetail } from '@/types/channel';
  4. import ChatSidebar from './ChatSidebar';
  5. import DonationModal from './DonationModal';
  6. import Link from 'next/link';
  7. import './style.scss';
  8. type Props = {
  9. channel: ChannelDetail;
  10. };
  11. export default function WatchView({ channel }: Props) {
  12. const [showDonation, setShowDonation] = useState(false);
  13. const embedUrl = channel.videoId
  14. ? `https://www.youtube.com/embed/${channel.videoId}?autoplay=1&mute=1`
  15. : null;
  16. return (
  17. <div className="watch-page">
  18. <div className="watch-page__content">
  19. {/* 플레이어 */}
  20. <div className="watch-page__player">
  21. {embedUrl ? (
  22. <iframe
  23. src={embedUrl}
  24. allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
  25. allowFullScreen
  26. title={channel.liveTitle || channel.name}
  27. />
  28. ) : (
  29. <div className="watch-page__offline">
  30. <p>현재 방송 중이 아닙니다</p>
  31. <Link href={`/channel/${channel.channelSID}`}>채널 페이지로 이동</Link>
  32. </div>
  33. )}
  34. </div>
  35. {/* 채널 정보 */}
  36. <div className="watch-page__info">
  37. <h1 className="watch-page__title">{channel.liveTitle || channel.name}</h1>
  38. <div className="watch-page__channel">
  39. <Link href={`/channel/${channel.channelSID}`} className="watch-page__channel-name">
  40. {channel.name}
  41. {channel.isVerified && <span className="watch-page__verified" title="인증됨">✓</span>}
  42. </Link>
  43. {channel.handle && <span className="watch-page__handle">@{channel.handle}</span>}
  44. </div>
  45. <div className="watch-page__actions">
  46. <button type="button" className="watch-page__donate-btn" onClick={() => setShowDonation(true)}>
  47. 💰 후원하기
  48. </button>
  49. </div>
  50. </div>
  51. </div>
  52. {/* 우측 채팅 */}
  53. <div className="watch-page__chat">
  54. <ChatSidebar onDonate={() => setShowDonation(true)} />
  55. </div>
  56. {/* 후원 모달 */}
  57. {showDonation && (
  58. <DonationModal
  59. channelSID={channel.channelSID}
  60. onClose={() => setShowDonation(false)}
  61. />
  62. )}
  63. </div>
  64. );
  65. }